webix.ready(function(){
  var params=new Array();
  var URL="";
  var my_template={
      template: "<span style='font-size:20px; font-weight:bold; color:#3498DB'; >领用回收记录详情</span>&nbsp;/&nbsp;&nbsp;UseRecordDetails <input type='button' value=' 导 出 ' onclick='exportExcel()' style='background: #268fd5;background: 1px solid #268fd5;color: #fff;'>",
      height:45,
      borderless:true 
  };
 
  var my_datatable={
      view:"datatable",
      id:"mydatatable",     
      columns:[
               {id:"simple_specs_cust",header:["规格简称"],fillspace:true},
               {id:"long_specs_cust",header:["规格全称"],fillspace:true},
        {id:"cutter_specs",header:["规格"],fillspace:true,hidden:true},
        {id:"supp_name",header:["供应商",{content:"textFilter"}],fillspace:true},
        {id:"useCount",header:"领用数量",fillspace:true},
        {id:"recCount",header:"回收数量",fillspace:true}
      ],      
      height:700,  
      select:true,
      editable:true,
      checkboxRefresh:true,
      // url:URL
  };
  var page={
    view:"pager",
    id:"pagerA",
    count:1000,
    master:false,
    group:15,
    size:5,
    page:1,
    template:"{common.first()}{common.prev()}{common.pages()}{common.next()}{common.last()}",
    css:"pager",
    on: {
      onItemClick: function(id, e, node){
        if (id == "next") {
          if($$("pagerA").config.limit==$$("pagerA").config.page+1)
            {
              id = $$("pagerA").config.limit-1;
            }
          else
          {
            id=$$("pagerA").config.page+1;
          }
        }
        else if(id=="prev")
        {
          id=$$("pagerA").config.page-1; 
        }
        else if(id=="first")
        {
          id=0;
        }
        else if(id=="last")
        {
          id=$$("pagerA").config.limit-1;
        } 
         var params={};
        params.start_date = $("#start_date").val();
        params.end_date = $("#end_date").val();
        params.operator_id = $("#operator_id").val();
        params.currPage =parseInt(id)+1;
        params.pageSize =20;
        postData("ajaxGetCutterUseListByOperatorId", params,callback);
      }
    },
    height:38,
    css:{"text-align": "center","margin-top":"20px!important"}
  };
  var params={};
  params.start_date = $("#start_date").val();
  params.end_date = $("#end_date").val();
  params.operator_id = $("#operator_id").val();
  params.pageSize =20;
  postData("ajaxGetCutterUseListByOperatorId", params,callback);
  var web={
      container:"body",
      type:"line",
      id:"mylayout",
      rows:[
        my_template,
        {height:20},
        my_datatable,
        page
      ],
  };
  webix.ui(web);//---webix.ui结束----   
  function callback(data){
    var obj =JSON.parse(data); 
    var text1 = obj.data;
    var data = new webix.DataCollection({data:text1.page});
    $$('mydatatable').data.sync(data);
    $$("pagerA").define("limit",text1.totalPageCount);
    $$("pagerA").define("count",text1.totalCount);
    $$("pagerA").define("size",text1.pageSize);
    $$("pagerA").define("page",text1.currPage-1);
    $$('pagerA').refresh();
  }
/*-------all end----------*/
});             



